import http from "@/utils/request"



// 登入

//jsdoc注释

/**
 * 
 * @param {string} username 用户名
 * @param {string} password 密码
 * @returns {Promise} axios的请求对象
 */

export const loginApi = (username, password) => http.post("/users/login", {
    username,
    password
})

//获取验证码

export const getCaptchaApi = () => http.get("/users/getCaptcha?v=next")

//检验验证码
/**
 * 
 * @param {string} captcha 用户输入的验证码
 * @returns 
 */
export const verifyCaptchaApi = captcha => http.get(`/users/verifyCaptcha?captcha=${captcha}`)

//获取登入日志

export const getLoginLogApi = (currentPage = 1, pageSize = 13) => http.get("/getloginlog", {
    params: {
        page: currentPage,
        count: pageSize
    }
})

//搜索日志

export const searchLogApi = (key = "", currentPage = 1, pageSize = 13) => http.get("/getloginlog/search", {
    params: {
        key,
        page: currentPage,
        count: pageSize
    }
})

//获取有的用户信息

// page	
// 1
// 否	String	
// 分页页码
// count	
// 5
// 否	String	
// 分页数量
// username	
// lbw
// 否	String	
// 搜索的用户名
// order_by	
// -1
// 否	String	
// 排序规则 1是正序 -1是倒序
// phone	
// 123
// 否	String	
// 手机号

export const getUsersApi = (params) => http.get("users/getAllUsers", {
    params
})


//修改用户

export let updateUserApi = (params = {}) => http.post('/users/updateUser', params)

//添加用户

export let addUserApi = (params = {}) => http.post('/users/addUser', params)

//删除用户

export let deleteUserApi = (params = {}) => http.get('/users/deleteUser', {
    params
})